<?php
namespace app\api\controller\com;
class Patch extends Base {
	//列表
	public function lists() {
		$d = $this->post;
		$uuid = $d['uuid'];
		if (!empty($uuid)) {
			$patch = $this->db->query("select id,uuid,cat_title,sort from patch_cat where uuid = ?", [$uuid], 1);
			$patch['childlist'] = $this->db->query("select title,sort,content from patch where cat_id=? order by sort desc,id desc", [$patch['id']]);
		} else {
			$patch = [];
			$list = $this->db->query("select id,uuid,cat_title,sort from patch_cat");
			foreach ($list as $key => $val) {
				$val['childlist'] = $this->db->query("select title,sort,content from patch where cat_id=? order by sort desc,id desc", [$val['id']]);
				$patch[$val['uuid']] = $val;
				unset($patch[$key]);
			}
		}
		suc($patch);
	}
}
